<div id="clients_journal" class="stn_journal">
	<div style="padding: 5px 5px 5px 5px">
		<?php foreach($tools_clients as $tool) { ?>
			<?php echo $tool; ?>
		<?php } ?>	
	</div>
	<div>
		<?php
			$data = array("name"=>"clients_activerecord",
							"id"=>"clients_activerecord",
							"value"=>'',
							"type"=>'hidden'
							); 
			echo form_input($data);
		?>
		<table border="0" cellpadding="4" cellspacing="0" >
			<tr>
				<th align="left" class="journal_header">
					ID
				</th>
				<th align="left" class="journal_header">
					<?php echo $f_name; ?>
				</th>
				<th align="left" class="journal_header">
					<?php echo $s_name; ?>
				</th>
				<th align="left" class="journal_header">
					<?php echo $l_name; ?>
				</th>

				<th align="left" class="journal_header">
					<?php echo $birthday; ?>
				</th>

				<th align="left" class="journal_header">
					<?php echo $f_pass_seria; ?>
				</th>

				<th align="left" class="journal_header">
					<?php echo $f_pass_num; ?>
				</th>

				<th align="left" class="journal_header">
					<?php echo $f_pass_period; ?>
				</th>

				<th align="left" class="journal_header">
					<?php echo $zk; ?>
				</th>

				<th align="left" class="journal_header">
					<?php echo $tourist; ?>
				</th>

			</tr>	
			<?php foreach($DST as $row) {?>
				<tr class=""  
					onclick="setActiveRecord('clients', '<?php echo $row->_clients_rid?>');" 
					id="clients_<?php echo $row->_clients_rid?>"
					ondblclick="setActiveRecord('clients', '<?php echo $row->_clients_rid?>');clients_edit();"
				>
					<td>
						<?php echo $row->_clients_rid; ?>&nbsp;
					</td>
					<td>
						<?php echo $row->f_name; ?>&nbsp;
					</td>
					
					<td>
						<?php echo $row->s_name; ?>&nbsp;
					</td>
					
					<td>
						<?php echo $row->l_name; ?>&nbsp;
					</td>
					<td>
						<?php echo $row->birthday; ?>&nbsp;
					</td>
					<td>
						<?php echo $row->f_pass_seria; ?>&nbsp;
					</td>
					<td>
						<?php echo $row->f_pass_num; ?>&nbsp;
					</td>
					<td>
						<?php echo $row->f_pass_period; ?>&nbsp;
					</td>
					<td>
						<INPUT TYPE=RADIO NAME="zk_rid" id="zk_rid<?php echo $row->_clients_rid; ?>" VALUE="<?php echo $row->_clients_rid; ?>" onchange="setZkClientsRid();">
					</td>
					<td>
						<INPUT TYPE=CHECKBOX DISABLED NAME="tourist_<?php echo $row->_clients_rid; ?>" id="tourist_<?php echo $row->_clients_rid; ?>" onchange="javascript: if (this.checked==true) document.getElementById('_zk_is_tourist').value = '1'; else document.getElementById('_zk_is_tourist').value = '0';">
					</td>
				</tr>
			<?php } ?>
		</table>
		<script language="javascript">
			function onLoadElements(){
				var zkRid = document.getElementById('_zk_rid').value;
				var isTourist = document.getElementById('_zk_is_tourist');			
				if (zkRid != '0' && zkRid != ''){
					if(document.forms[0].zk_rid.length == undefined){
						if(document.forms[0].zk_rid.value==zkRid) {
							document.forms[0].zk_rid.checked=true;
							if(isTourist.value != '0'){
								document.getElementById('tourist_'+zkRid).checked = true;
							}
							document.getElementById('tourist_'+zkRid).disabled = false;
							return;
						}
					}
					for(var i = 0; i < document.forms[0].zk_rid.length; i++) {
						if(document.forms[0].zk_rid[i].value==zkRid) {
							document.forms[0].zk_rid[i].checked=true;
							if(isTourist.value != '0'){
								document.getElementById('tourist_'+zkRid).checked = true;
							}
							document.getElementById('tourist_'+zkRid).disabled = false;
						}
					}
				}
			}
			function setZkClientsRid(){
				var zkRid = document.getElementById('_zk_rid');
				var isTourist = document.getElementById('_zk_is_tourist');
				if(document.forms[0].zk_rid.length == undefined){
					if(document.forms[0].zk_rid.checked) {
						if(zkRid.value != '0' && zkRid.value != ''){
							var checkboxObject = document.getElementById('tourist_'+zkRid.value);
							checkboxObject.checked = false;
							checkboxObject.disabled = true;
						}
						zkRid.value = document.forms[0].zk_rid.value;
						isTourist.value = '0';
						var checkboxObject = document.getElementById('tourist_'+document.forms[0].zk_rid.value);
						checkboxObject.disabled = false;
					}
					return;
				}
				for(var i = 0; i < document.forms[0].zk_rid.length; i++) {
					if(document.forms[0].zk_rid[i].checked) {
						if(zkRid.value != '0' && zkRid.value != ''){
							var checkboxObject = document.getElementById('tourist_'+zkRid.value);
							checkboxObject.checked = false;
							checkboxObject.disabled = true;
						}
						zkRid.value = document.forms[0].zk_rid[i].value;
						isTourist.value = '0';
						var checkboxObject = document.getElementById('tourist_'+document.forms[0].zk_rid[i].value);
						checkboxObject.disabled = false;
					}
				}
			}
			onLoadElements();
		</script>
	</div>
</div>			